package com.holiday.springboot2.listener;


import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * 应用启动监听器 ServletContextListener，应用启动的时候就会执行这个类
 *   重写方法
 *      1、contextInitialized：容器初始化的时候执行
 *      2、contextDestroyed：容器销毁的时候执行
 */
@WebListener
public class ApplicationListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContextListener.super.contextInitialized(sce);
        System.out.println("contextInitialized");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        ServletContextListener.super.contextDestroyed(sce);
        System.out.println("contextDestroyed");
    }
}
